<template>
	<view>

		<!-- <u-notice-bar v-if="newShow" @click="goNew" mode="horizontal" :list="notice"></u-notice-bar> -->

		<view v-if="role==2 || role ==3"
			style="background: linear-gradient(180deg,#e0f4ff, #f8f9f9);display: inline-block;width: 100%;padding-bottom: 40rpx;">
			<view style="display: flex;justify-content: flex-end;margin: 20rpx;">
				<u-button v-if="role==3" @click="$Go('/pages/my/store')" type="primary" size="mini"
					:custom-style="{backgroundColor:'#fff',fontSize:'24rpx',color:'#2D9AFE'}" shape="circle"> 我要提现
				</u-button>
			</view>
			<view class="u-flex u-row-around u-text-center u-margin-top-60" style="color: #333;">
				<view>
					<view style="font-size: 40rpx;font-weight: bold;">
						￥{{menony}}
					</view>
					<view class="u-margin-top-20">余额</view>
				</view>
				<view>
					<view style="font-size: 40rpx;font-weight: bold;">
						{{user_num}}
					</view>
					<view class="u-margin-top-20">会员数量</view>
				</view>
			</view>
		</view>

		<List :list="list" v-if="role" @go='go'></List>

		<!-- <u-loadmore :status="initial.status" /> -->




	</view>
</template>

<script>
	import loader from '@/common/loadPage.js';
	import List from '@/pages/store/components/list';

	import wxLocation from '@/common/location.js';

	export default {
		components: {
			List
		},
		mixins: [loader],
		data() {
			return {

				nav: [{
					name: '车位'
				}, {
					name: '订单'
				}],
				current: 0,
				list: [],
				initial: {
					page: 1,
					geturl: "/alliance/store",
					parm: {
						lat: '',
						lng: ""
					},
					isPage: true
				},
				menony: "",
				user_num: '',
				role: '',
				newShow: false

			}
		},
		methods: {
			message() {
				this.$u.post('/Alliance/message	', {}).then(res => {
					if (res.length) {
						this.newShow = true
					}
				}).catch(err => {})
			},

			infomation() {

				return new Promise((resolve, reject) => {
					this.$u.api.userInfo().then(res => {
						this.role = res.role;
						resolve(res)
					}).catch(err => {

					})
				})

			},

			jiazai() {

				this.$u.post('/alliance/info', {}).then(res => {
					this.menony = res.balance;
					this.user_num = res.userNum
				}).catch(err => {})
			},
			change(index) {
				this.current = index;
			},
			go(e) {
				uni.navigateTo({
					url: '/pages/myStore/detail?id=' + e.id
				})
			}

		},
		onLoad() {




		},
		async onShow() {
			await this.infomation()
			const wx = new wxLocation();
			wx.getAddress().then(res => {
				this.initial.parm.lat = res.result.location.lat;
				this.initial.parm.lng = res.result.location.lng;
				this.getGoods();
			}).catch(err => {

			})
			this.jiazai()
			this.message()
		}
	}
</script>

<style>
</style>
